import { ListType } from "../../reducer/list";
import { Store } from "../../reducer";

export const dealListData = {
  otherFilter: () => {},
  recommend: (store: Store) => {
    store.list.resetList();
  },
  time: (store: Store, state: boolean, list: ListType[]) => {
    const newList = [...list];
    state
      ? newList.sort((a, b) => a.seconds - b.seconds)
      : newList.sort((a, b) => b.seconds - a.seconds);
    store.list.setList(newList);
  },
  price: (store: Store, state: boolean, list: ListType[]) => {
    const newList = [...list];
    state
      ? newList.sort((a, b) => a.realPrice - b.realPrice)
      : newList.sort((a, b) => b.realPrice - a.realPrice);
    store.list.setList(newList);
  },
};
